<template>
  <v-card title="树表格">
    <div class="mb-30">
      <v-alert type="info" class="mb-10">
        <div slot="message">
          <div>
            设置好树节点是在什么字段
            <span class="blue-text"> loadOptions.treeField </span>
          </div>
          <div>
            如果你的数据是扁平化的（ <span class="red-text"> 必须有id和parentId </span> ）不需要开启：
            <span class="blue-text"> treeConfig.transformSetup </span>
          </div>
        </div>
      </v-alert>
      <div class="mb-5"></div>
      <vcu-table
        ref="xTable"
        show-overflow
        :loadOptions="options"
        :height="200"
        :tree-config="{
          indent: 10,
          trigger: 'row',
          transform: true,
          transformSetup: { children: 'childNodeList' },
        }"
        :scroll-y="{ gt: 20 }"
      >
      </vcu-table>
    </div>

    <div class="mb-30">
      <v-alert type="info" class="mb-10">
        <div slot="message">
          <div>
            当通用平台返回数据没有id,parentId且是树形结构数据,要设置
            <span class="blue-text"> transformSetup.createId </span>
            为true
          </div>
        </div>
      </v-alert>
      <v-button @click="ontest">测试</v-button>
      <div class="mb-5"></div>
      <vcu-table
        ref="xTable1"
        show-overflow
        :loadOptions="options1"
        :height="200"
        :tree-config="{
          trigger: 'row',
          transform: true,
          transformSetup: { children: 'children', createId: true },
        }"
        :scroll-y="{ gt: 20 }"
      >
      </vcu-table>
    </div>

  </v-card>
</template>
<script>
export default {
  data() {
    return {
      options: {
        headUrl: "api/header/treetable",
        pageUrl: "api/page/treetable",
        seq: true,
        treeField: "name",
        loadNodes: (res)=>{
          return res.data.payload;
        }
      },
      options1: {
        headUrl: "api/header/scrollTreeData",
        pageUrl: "api/page/scrollTreeData",
        seq: true,
        treeField: "seq",
        seqWidth: 300
      },
    };
  },
  mounted() {},
  methods: {
    ontest(){
      console.info(this.$refs.xTable1.getTableData())
    }
  },
};
</script>
